<?php
require_once('functions.php');
require_once('lib/nusoap.php');

$server = new soap_server();
$server->configureWSDL('PozrService', 'urn:PozrService');

$server->wsdl->addComplexType(
		'Measurement', 
		'complexType',
		'struct',
		'all',
		'',
		array( 'hash' => array('name' => 'hash', 'type' => 'xsd:string'),
			's_type' => array('name' => 's_type', 'type' => 'xsd:unsignedByte'),
			'm_type' => array('name' => 'm_type', 'type' => 'xsd:boolean'),
			'lat' => array('name' => 'lat', 'type' => 'xsd:float'),
			'lon' => array('name' => 'lon', 'type' => 'xsd:float'),
			'alt' => array('name' => 'alt', 'type' => 'xsd:float'),
			'strength' => array('name' => 'strength', 'type' => 'xsd:short')
			)
		);

$server->wsdl->addComplexType(
		'MeasurementList',
		'complexType',
		'array',
		'',
		'SOAP-ENC:Array',
		array(),
		array(
			array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:Measurement[]')
			),
		'tns:Measurement'
		);

$server->register("SendRawMeasurement",
		array('measurement_list' => 'tns:MeasurementList'),
		array('return' => 'xsd:boolean'),
		'urn:PozrService',
		'urn:PozrService#SendRawMeasurement',
		'rpc',
		'encoded',
		'Adds new raw signal measurement data to the database.');

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);


?>